package com.dbt.admin.service.impl;

import com.dbt.admin.domain.entity.SysUser;
import com.dbt.admin.mapper.MybatisTestMapper;
import com.dbt.admin.service.MybatisTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author fangkun
 * @create 2022-08-16-16:47
 */
@Service
public class MybatisTestServiceImpl implements MybatisTestService {

    @Autowired
    MybatisTestMapper mybatisTestMapper;

    @Override
    public SysUser selectById(int id) {
        return mybatisTestMapper.selectById(id);
    }

    @Override
    public int insertUser(SysUser user) {

        user.setCreateTime(new Date());
        int res = mybatisTestMapper.insertUser(user);
        return res;
    }

    @Override
    public int updateById(Long id) {
        SysUser user = new SysUser();
        user.setUserId(id);
        user.setUpdateTime(new Date());
        user.setUpdateBy("men");
        int res = mybatisTestMapper.updateById(user);
        return res;
    }

    @Override
    public int deleteById(Long id) {

        int res = mybatisTestMapper.deleteById(id);

        return res;
    }

    @Override
    public List<SysUser> selectUser(SysUser user) {

        List<SysUser> userList = mybatisTestMapper.selectUser(user);

        return userList;
    }
}
